package com.yf.repo.modules.repo.dto.ext;

import com.yf.repo.modules.repo.dto.RepoDTO;
import com.yf.system.modules.user.dto.SysUserDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
* <p>
* 题库详情扩展类
* </p>
*
* @author 聪明笨狗
* @since 2020-05-25 13:23
*/
@Data
@ApiModel(value="题库详情扩展类", description="题库详情扩展类")
public class RepoDetailDTO extends RepoDTO {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "章节列表")
    private List<ChapterExtDTO> chapters;

    @ApiModelProperty(value = "题型统计", required=true)
    private List<RepoTypeCountDTO> typeList;

    @ApiModelProperty(value = "部门列表", required=true)
    private List<String> deptCodes;

    @ApiModelProperty(value = "指定人员列表", required=true)
    private List<SysUserDTO> personList;

    @ApiModelProperty(value = "是否购买", required=true)
    private Boolean isBuy;

    @ApiModelProperty(value = "主观题数量", required=true)
    private Integer subjCount;

    @ApiModelProperty(value = "客观题数量", required=true)
    private Integer objCount;

    @ApiModelProperty(value = "题目总数", required=true)
    private Integer quCount;



    public Integer getQuCount(){
        if(CollectionUtils.isEmpty(this.typeList)){
            return 0;
        }

        int count = 0;
        for(RepoTypeCountDTO item: typeList){
            count+=item.getCount();
        }
        return count;
    }

}
